#ifndef CREUSATOR_H
#define CREUSATOR_H

#include <QDebug>
#include <QWidget>
#include <QResizeEvent>
#include "game.h"
#include <QGLWidget>

#define TIMER_INTERVAL 50

class Creusator : public QGLWidget
{
public:
    Creusator(QWidget *parent = 0);

    int getNormalWidth();
    int getNormalHeight();
    QStringList getSavedGamesList();
    QStringList getLevelsList();

    void startGame();
    void pauseGame();
    void endGame();
    void switchPauseGame();
    void saveGame(QString name, int pos);
    void loadGame(int pos);
    void newGame(QStringList levels);
    void removeSavedGame(int pos);

protected:
    void paintEvent(QPaintEvent *event);
    void resizeEvent(QResizeEvent *event);
    void keyPressEvent(QKeyEvent *event);
    void keyReleaseEvent(QKeyEvent *event);
    void timerEvent(QTimerEvent *event);

 private:
    void init();
    void fixPainterRatio(QPainter *painter);
    int keyPressed();
    void testMap(Map *map);
    Level * testLevel();

private:
    Game *m_game;
    bool m_leftPressed, m_upPressed, m_rightPressed, m_downPressed;
    int m_globalTimerId;
    int m_globalTimerInterval;
    int m_nLevels;
    bool m_pause;
    bool m_win;
    bool m_loose;

};

#endif // CREUSATOR_H
